import request from '@/utils/request'
import { ObjToQueryString } from '@/utils/method'
const baseUrl = process.env.VUE_APP_BASE_API
export function login({ username, password }) {
  const data = new FormData()
  data.append('username', username)
  data.append('password', password)
  return request({
    url: '/employee/login',
    method: 'post',
    data
  })
}
export const getMenu = (userId) => {
  return request({
    url: `/menu/tree/${userId}`,
    method: 'get'
  })
}

export const logout = () => {
  return request({
    url: '/vue-element-admin/user/logout',
    method: 'post'
  })
}
// 用户列表
export const getUserList = (params) => {
  return request({
    url: '/user/list',
    params,
    method: 'get'
  })
}
// 用户信息
export const getRecently = (userId) => {
  return request({
    url: `/user/login/recently/${userId}`,
    method: 'get'
  })
}
export const getPersonalInfo = (userId) => {
  return request({
    url: `/user/info/${userId}`,
    method: 'get'
  })
}
export const getUserLevel = (params) => {
  return request({
    url: '/loanUserLevel/queryByParam',
    params,
    method: 'get'
  })
}
export const getPageNameList = () => {
  return request({
    url: '/channel/package',
    method: 'get'
  })
}
export const orderUnionQuery = (params) => {
  return request({
    url: '/order/unionQuery',
    params,
    method: 'get'
  })
}
export const downloadPageNameList = (params) => {
  const url = '/order/unionQuery/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 认证详情
export const getAuthInfo = (userId) => {
  return request({
    url: `/user/anthInfo/${userId}`,
    method: 'get'
  })
}
// 绑定银行详情
export const getBankCard = (userId) => {
  return request({
    url: `/account/bankcard/${userId}`,
    method: 'get'
  })
}
// 包名
export const allPackage = () => {
  return request({
    url: '/channel/package',
    method: 'get'
  })
}
